import 'package:flutter/material.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

import '../tool/assets.dart';
import 'search_row.dart';

class SearchView extends BLESearchDeviceDialog implements BLESearchDeviceDialogDelegate {
  SearchView({
    super.key,
    super.height,
  }) : super() {
    delegate = this;
  }

  @override
  Color? get contentColor => Color_Bottom_bg;

  @override
  Widget? bgViewForFooter(Widget child) => null;

  @override
  Widget? bgViewForHeader(Widget child) {
    return Container(color: Color_theme, child: child);
  }

  @override
  String filterName() => 'CB';

  @override
  List<RowModel> listModelForFooter(String appVersion) => [];

  @override
  List<RowModel> listModelForHeader(String appVersion) {
    return ['Devices']
        .map(($0) => RowModel(
            text: $0,
            height: 60,
            textStyle: const TextStyle(fontSize: 20, color: Colors.white),
            lineColor: Color_Line_bg,
            lineHeight: 1,
            bgColor: Colors.transparent))
        .toList();
  }

  @override
  List<RowModel> listModelForSection(List<String> list) {
    return (list)
        .map(($0) => RowModel(
            text: $0,
            height: 40,
            textStyle: const TextStyle(fontSize: 14, color: Colors.white),
            lineColor: Color_Bottom_bg,
            lineHeight: 1,
            bgColor: Colors.transparent,
            iconName: '',
            iconSize: 20))
        .toList();
  }

  @override
  void methodForClickBLESearchTableView(BLESearchTableViewClickType type, String tag) {
    if (type == BLESearchTableViewClickType.footer) {}
  }

  @override
  void refreshMethodExentesion() {}

  @override
  Widget viewForRowInSection(DSPeripheral peripheral, int section, int row, _) {
    return SearchItem(
      device: peripheral,
      onSelect: () => clickDevice(section, row),
      onPressLongToChangeName: () => true ? null : changeDeviceName(section, row, peripheral.peripheral),
    );
  }
}
